﻿Imports System.Net.Mail

Public Class sendMail
    Public Shared Sub SendEmailFromGmailMail(ByVal mailTo As String, ByVal pass As String, ByRef ResultLabel As String)

        Dim Mail As New MailMessage
        Try
            Mail.Subject = "Phục hồi mật khẩu của ứng dụng quản lý thư viện - No reply"
            Mail.To.Add(mailTo)
            Mail.From = New MailAddress("lnt11ck3@gmail.com")

            Mail.Body = "Xin chào bạn." & vbNewLine
            Mail.Body += "Mật khẩu mới của bạn là " + pass.ToString

            Dim SMTP As New SmtpClient("smtp.gmail.com")
            SMTP.EnableSsl = True

            SMTP.Credentials = New System.Net.NetworkCredential("lnt11ck3@gmail.com", "12345qazxc")

            SMTP.Port = 587

            SMTP.Send(Mail)

            ResultLabel = "Mật khẩu mới của bạn đã được gửi vào email, Vui lòng kiểm tra lại email!"

        Catch ex As Exception
            ResultLabel = ex.Message

        End Try
    End Sub
End Class
